﻿using System;
using System.Collections.Generic;
using System.Text;

namespace IVideo
{
    /// <summary>
    /// 获取初始化参数回调委托
    /// </summary>
    /// <param name="parameters"></param>
    /// <returns></returns>
    public delegate string[] GetParametersCallback(params string[] parameters);

    /// <summary>
    /// 透明通道回调委托
    /// </summary>
    /// <param name="message">通过透明通道向设备串口发送数据</param>
    public delegate void Transfer485Callback(byte[] message);

    /// <summary>
    /// 码流数据回调委托
    /// </summary>
    /// <param name="buffer">缓冲区的指针</param>
    /// <param name="bufferSize">缓冲区的大小</param>
    /// <returns>true表示成功，false表示失败</returns>
    public delegate bool RealStreamCallback(IntPtr buffer, uint bufferSize);

    /// <summary>
    /// 视频绘图回调函数
    /// </summary>
    /// <param name="hDC">绘图句柄</param>
    public delegate void PaintCallback(IntPtr hDC);

    /// <summary>
    /// 视频SDK接口，为各种平台的SDK提供了统一的接口
    /// </summary>
    public interface IVideoSDK
    {   
        /// <summary>
        /// 设置码流数据回调委托
        /// </summary>
        RealStreamCallback RealStreamCallback { set; }

        /// <summary>
        ///设置获取初始化参数回调委托
        /// </summary>
        GetParametersCallback GetParametersCallback { set; }

        /// <summary>
        /// 设置透明通道回调委托
        /// </summary>
        Transfer485Callback Transfer485Callback { set; }

        /// <summary>
        /// 视频绘图回调函数
        /// </summary>
        PaintCallback PaintCallback { set; }

        /// <summary>
        /// 是否已经登录
        /// </summary>
        bool IsLogined { get; }

        /// <summary>
        /// 视频是否已经打开
        /// </summary>
        bool IsOpened { get; }

        /// <summary>
        /// 是否正在录像
        /// </summary>
        bool IsRecording { get; }

        /// <summary>
        /// 透明通道是否已经打开
        /// </summary>
        bool IsTransferOpened { get; }

        /// <summary>
        /// 登录编码器
        /// </summary>
        /// <param name="ip">编码器IP</param>
        /// <param name="port">编码器端口</param>
        /// <param name="user">编码器用户名</param>
        /// <param name="password">编码器密码</param>
        /// <returns>是否登录成功</returns>
        bool LoginEncoder(string ip, ushort port, string user, string password);

        /// <summary>
        /// 从编码器上注销
        /// </summary>
        /// <returns>是否从编码器上注销成功</returns>
        bool LogoutEncoder();

        /// <summary>
        /// 打开视频，实时预览，并对视频进行解码
        /// </summary>
        /// <param name="channel">要打开视频的通道</param>
        /// <param name="handle">视频流将要显示的窗体的句柄</param>
        /// <returns>视频是否打开成功</returns>
        bool OpenVideoDecode(byte channel, IntPtr handle);

        /// <summary>
        /// 打开视频，实时预览
        /// </summary>
        /// <param name="channel">要打开视频的通道</param>
        /// <param name="handle">视频流将要显示的窗体的句柄</param>
        /// <returns>视频是否打开成功</returns>
        bool OpenVideo(byte channel, IntPtr handle);

        /// <summary>
        /// 关闭视频
        /// </summary>
        /// <returns>视频是否关闭成功</returns>
        bool CloseVideo();

        /// <summary>
        /// 对视频进行抓拍
        /// </summary>
        /// <param name="file">抓拍的图像文件将要保存的文件路径名</param>
        /// <returns>是否抓拍成功</returns>
        bool SnapVideo(string file);

        /// <summary>
        /// 开始录像
        /// </summary>
        /// <param name="file">将要保存录像的录像文件名</param>
        /// <returns>开始录像是否成功</returns>
        bool StartRecord(string file);

        /// <summary>
        /// 停止录像
        /// </summary>
        /// <returns>停止录像是否成功</returns>
        bool StopRecord();

        /// <summary>
        /// 云台左转
        /// </summary>
        /// <param name="speed">云台转动的速度,范围为1到7</param>
        /// <returns>true表示成功，false表示失败</returns>
        bool PanLeft(byte speed);

        /// <summary>
        /// 云台右转
        /// </summary>
        /// <param name="speed">云台转动的速度,范围为1到7</param>
        /// <returns>true表示成功，false表示失败</returns>
        bool PanRight(byte speed);

        /// <summary>
        /// 云台上仰
        /// </summary>
        /// <param name="speed">云台转动的速度,范围为1到7</param>
        /// <returns>true表示成功，false表示失败</returns>
        bool TiltUp(byte speed);

        /// <summary>
        /// 云台下俯
        /// </summary>
        /// <param name="speed">云台转动的速度,范围为1到7</param>
        /// <returns>true表示成功，false表示失败</returns>
        bool TiltDown(byte speed);

        /// <summary>
        /// 云台上仰和左转
        /// </summary>
        /// <param name="speed">云台转动的速度,范围为1到7</param>
        /// <returns>true表示成功，false表示失败</returns>
        bool PanLeftTiltUp(byte speed);

        /// <summary>
        /// 云台下俯和左转
        /// </summary>
        /// <param name="speed">云台转动的速度,范围为1到7</param>
        /// <returns>true表示成功，false表示失败</returns>
        bool PanLeftTiltDown(byte speed);

        /// <summary>
        /// 云台上仰和右转
        /// </summary>
        /// <param name="speed">云台转动的速度,范围为1到7</param>
        /// <returns>true表示成功，false表示失败</returns>
        bool PanRightTiltUp(byte speed);

        /// <summary>
        /// 云台下俯和右转
        /// </summary>
        /// <param name="speed">云台转动的速度,范围为1到7</param>
        /// <returns>true表示成功，false表示失败</returns>
        bool PanRightTiltDown(byte speed);

        /// <summary>
        /// 焦距变小(倍率变小)
        /// </summary>
        /// <returns>true表示成功，false表示失败</returns>
        bool ZoomOut();

        /// <summary>
        /// 焦距变大(倍率变大)
        /// </summary>
        /// <returns>true表示成功，false表示失败</returns>
        bool ZoomIn();

        /// <summary>
        /// 焦点前调
        /// </summary>
        /// <returns>true表示成功，false表示失败</returns>
        bool FocusNear();

        /// <summary>
        /// 焦点后调
        /// </summary>
        /// <returns>true表示成功，false表示失败</returns>
        bool FocusFar();

        /// <summary>
        /// 光圈缩小
        /// </summary>
        /// <returns>true表示成功，false表示失败</returns>
        bool IrisClose();

        /// <summary>
        /// 光圈扩大
        /// </summary>
        /// <returns>true表示成功，false表示失败</returns>
        bool IrisOpen();

        /// <summary>
        /// 云台停止转动
        /// </summary>
        /// <returns>true表示成功，false表示失败</returns>
        bool PTZStop();

        /// <summary>
        /// 开启透明通道
        /// </summary>
        /// <returns>开启透明通道是否成功</returns>
        bool OpenTransfer485();

        /// <summary>
        /// 通过透明通道向设备串口发送数据
        /// </summary>
        /// <param name="Message">将要发送的数据</param>
        /// <returns>通过透明通道向设备串口发送数据是否成功</returns>
        bool SendTransfer485(byte[] Message);

        /// <summary>
        /// 关闭透明通道
        /// </summary>
        /// <returns>关闭透明通道是否成功</returns>
        bool CloseTransfer485();

    }
}
